<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
  <title>乐直播-硬件管理</title> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticvideoclip/portal/layui/css/layui.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticvideoclip/portal/css/le-main.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticvideoclip/libs/font-awesome-4.7.0/css/font-awesome.min.css?cdnv=0.16"> 
  <style type="text/css">
    .le-loud-img{
        position: relative;
        cursor: pointer;
    }
    .le-confirm-device, .le-confirm-test{
        position: absolute;
        top: 0;
        right: 0;
        padding: 3px 5px;
        border: 1px solid;
    }
        </style> 
 </head> 
 <body> 
  <div id="main"> 
   <div id="main-sortbar"> 
   </div> 
   <div id="main-itemlist"> 
    <ul class="le-hardware-content"> 
     <li> 
      <div class="le-loud-img"> 
       <img src="http://i0.letvimg.com/lc09_yunzhuanma/201708/22/10/20/b79295fcc7f295ba00277660b766a1d9_v2_NDg0OTE3MDM4/thumb/1_640_360.jpg"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
      </div> 
      <div class="le-loud-describe"> 
       <h2>打点录制：测试直播</h2> 
      </div> <input class="video-id" type="hidden" value="46a0985f69824018bfe9d590e815bcf5"> </li> 
     <li> 
      <div class="le-loud-img"> 
       <img src="http://i1.letvimg.com/lc09_yunzhuanma/201708/22/10/21/47f92f153be05f4076ce39d407328901_v2_NDg0OTE3MDYy/thumb/1_640_360.jpg"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
      </div> 
      <div class="le-loud-describe"> 
       <h2>测试直播</h2> 
      </div> <input class="video-id" type="hidden" value="53c7cbd6447d4cd498d4f3cc963808f7"> </li> 
     <li> 
      <div class="le-loud-img"> 
       <img src="http://i0.letvimg.com/lc10_yunzhuanma/201708/15/16/59/279f8434d04f8c4fc11749a4b48faff5_v2_NDg0NDU1MTgy/thumb/1_640_360.jpg"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
      </div> 
      <div class="le-loud-describe"> 
       <h2>手机版视频</h2> 
      </div> <input class="video-id" type="hidden" value="eacb9d2439aa4689b72ffa506a38b907"> </li> 
     <li> 
      <div class="le-loud-img"> 
       <img src="http://i1.letvimg.com/lc09_yunzhuanma/201706/12/10/27/ba064a3b59b44826b7c0e5c80d62922d_v2_NDc1NzQxMDM4/thumb/1_640_360.jpg"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
      </div> 
      <div class="le-loud-describe"> 
       <h2>Unveiling Dalaguete10月版本</h2> 
      </div> <input class="video-id" type="hidden" value="fc39a54fe8eb43b7a88cb6fad80b8954"> </li> 
    </ul> 
    <!--分页--> 
    <div class="le-pages"> 
     <a href="javascript:;" class="previous disabled">上一页</a> 
     <a href="javascript:;" class="active">1</a> 
     <a href="javascript:;" class="next disabled">下一页</a> 
    </div> 
    <div class="clearfix"></div> 
   </div> 
   <div id="main-form"> 
    <hr> 
    <form id="form" action=""> 
     <div class="plugin-btn"> 
      <input type="hidden" class="submit-video-id" name="video-id" value=""> 
      <button type="button" class="layui-btn" onclick="doSubmit()"> 选择视频</button> 
     </div> 
    </form> 
   </div> 
  </div> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/js/jquery.min.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/js/jquery.form.min.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/layui/layui.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/layui/lay/dest/layui.all.js?cdnv=0.16"></script> 
  <script>

        var cdnPath="http://cdn.lezhibo.com";//cdn路径
        function openLayer(url, title, func) {
            parent.openLayer(url,title,func);
        }
        function layerInit() {
            $("[layer-href]").click(function () {
                openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"))
            });
        }

        $("[confirm-href]").click(function () {
            var href = $(this).attr("confirm-href");
            if ((typeof(href) == "undefined") || href == null || href == "") {
                return;
            }

            var title = $(this).attr("confirm-title");
            if ((typeof(title) == "undefined") || title == null || title == "") {
                title = "您确定执行该操作吗？"
            }
            layer.confirm(title, {icon: 9, title: '确定操作 ？'}, function (index) {
                        layer.close(index);
                        $.get(href, function (result) {
                            if (result.isOk) {
                                location.reload();
                            } else {
                                alert(result.message);
                            }
                        });
                    },
                    function (index) {
                        layer.close(index);
                    });
        });

        var verification ={
            mobiel:function(){
                $mobile = $("input[validate='mobile']").val();
                var re = /^1\d{10}$/;
                if((typeof($mobile)!="undefined") && !re.test($mobile)){
                    $("input[validate='mobile']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的手机号</span></p>');
                    return false;
                }
            },
            empty:function(){
                var $input =$("input[validate='empty']");
                for(var i=0;i<$input.length;i++){
                    if($input.eq(i).val().trim().length==0){
                        $("input[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                        return false;
                    }
                }

                var $textarea =$("textarea[validate='empty']");
                for(var i=0;i<$textarea.length;i++){
                    if($textarea.eq(i).val().trim().length==0){
                        $("textarea[validate='empty']").eq(i).parent().after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span>/p>');
                        return false;
                    }
                }

                var $select =$("select[validate='empty']");
                for(var i=0;i<$select.length;i++){
                    if($select.eq(i).val().trim().length==0){
                        $("select[validate='empty']").eq(i).parent().after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                        return false;
                    }
                }
            },
            email:function(){
                $email=$("input[validate='email']").val();
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                if((typeof($email)!="undefined") && !re.test($email)){
                    $("input[validate='email']").after('<span class="le-tips"><span style="color: red;width: 100%">请输入正确的邮箱</span></p>');
                    return false;
                }
            },
            password: function () {
                $password = $("input[validate='password']").val();
                var re = /(.+){6,12}$/;
                if ((typeof($password) != "undefined") && !re.test($password)) {
                    $("input[validate='password']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入6到12位密码</span></p>');
                    return false;
                }
            },
            //正整数
            positiveInteger: function () {
                $positiveInteger = $("input[validate='positiveInteger']");
                var re=/^[1-9]\d*|0$/;
                for (var i = 0; i < $positiveInteger.length; i++) {
                    var every=$positiveInteger.eq(i).val().trim();
                    if ((typeof(every) != "undefined") && !re.test(every)) {
                        $("input[validate='positiveInteger']").eq(i).after('<p class="le-tips"><span style="color: red">请输入一个正整数或者0</span></p>');
                        return false;
                    }
                }
            }
         }


        var regularVerify = {
            mobile: function (value) {
                var re = /^1\d{10}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            email: function (value) {
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            password: function (value) {
                var re = /(.+){6,12}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            integer: function (value)     {
//                    var re = /^[1-9]\d*$/;
                var re = /^\d+$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            decimal: function (value) {
//                    var re = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/;
                var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            empty: function (value) {
                if (value.trim().length == 0) {
                    return false;
                }
            }
        }


        function leSubmit() {
            $("[le-submit]").click(function () {
                var $form = $(this).parents("form");
                var sfunc = $form.attr("success-func");
                var bfunc = $form.attr("before-func");
                $form.ajaxSubmit({
                    type: "post",
                    dataType: "json",
                    beforeSend: function () {
                        if (bfunc != null) {
                            if (false == eval(bfunc)) {
                                return false;
                            }
                        }
                        $(".le-tips").remove();
                        if (false == verification.empty()) {
                            return false;
                        }
                        if (false == verification.mobiel()) {
                            return false;
                        }
                        if (false == verification.email()) {
                            return false;
                        }
                        if (false == verification.password()) {
                            return false;
                        }
                        if (false == verification.positiveInteger()) {
                            return false;
                        }
                    },
                    success: function (result) {
                        if (sfunc != null) {
                            eval(sfunc);
                            return;
                        }

                        if (result.isOk) {
                            parent.isUpdateData = true;
                            parent.layer.closeAll();
                        } else {
                            layer.alert(result.message);
                        }
                    },
                    error: function () {
                        layer.alert("信息提交错误");
                    }
                });
            });
        }
        //对日期选择范围的控制
        //对id为begin-date和end-date的日期选择控件进行控制
        function verifyDate() {
            layui.use('laydate', function () {
                var laydate = layui.laydate;
                var start = {
                    format: 'hh:mm:ss',
                    istoday: false,
                    istime: true,
                    choose: function (datas) {
                        end.min = datas;    //开始日选好后， 重置结束日的最小日期
                        end.start = datas;  //将结束日的初始值设定为开始日
                    }
                };

                var end = {
                    format: 'hh:mm:ss',
                    istime: true,
                    istoday: false,
                    choose: function (datas) {
                        start.max = datas;  //结束日选好后, 重置开始日的最大日期
                    }
                };

                $('.begin-date').click(function () {
                    start.elem = this;
                    laydate(start);
                });
                $('.end-date').click(function () {
                    end.elem = this;
                    laydate(end);
                });

            });
        }


        layerInit();
        leSubmit();
        verifyDate();
//<script>
    $(function () {
        $(".le-hardware-content li").click(function () {
            $(".le-confirm-test").hide();
            $(this).find(".le-confirm-test").show();
            var id = $(this).find(".video-id").val();
            $(".submit-video-id").val(id);
        });
        $(".le-hardware-content li").mouseover(function () {
            $(this).find(".le-confirm-device").show();
        }).mouseout(function () {
            $(".le-confirm-device").hide();
        });
    });

    function doSubmit() {
        var id = $(".submit-video-id").val();
        if (id == null || id == "") {
            alert("请选择视频回放  ");
            return false;
        }
        location.href = "/videoClip/portal/_add?videoId=" + id;
    }
//</script>    
  <!--内容--> 
 </body>
</html>